{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
    <header class="main-box-header clearfix">
        <div class="pull-left">
            <h2>{$meta_title}（{$count}）</h2>
        </div>
        <div class="pull-right">
            <!-- <a href="{:url('add')}" class="btn btn-primary pull-right"> <i class="fa fa-plus-circle fa-lg"></i> 新增</a> -->
        </div>
    </header>
    <div class="main-box-body clearfix">
        {$Think.get.name}
        <div class="row">
            <form method="get">
                <div class="col-sm-12 col-md-4 col-lg-2">
                    <input type="text" class="form-control" name="username" value="{$Think.get.username}" placeholder="用户名">
                </div>
                <div class="col-sm-12 col-md-4 col-lg-2">
                    <input type="text" class="form-control" name="tel" value="{$Think.get.tel}" placeholder="电话">
                </div>
                <div class="col-sm-12 col-md-4 col-lg-2">
                    <select name="company_id" id="category" class="form-control">
                        <option value="">全部</option>
                        {volist name=":get_company_info()" id="vo"}
                        <option {eq name="$vo['id']" value="$Think.get.company_id"}selected{/eq}  value="{$vo.id}">{$vo.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="col-sm-12 col-md-4 col-lg-2">
                    <input type="text" class="form-control" name="start" value="{$Think.get.start}" placeholder="开始时间">
                </div>
                <div class="col-sm-12 col-md-4 col-lg-2">
                    <input type="text" class="form-control" name="end" value="{$Think.get.end}" placeholder="结束时间">
                </div>
                <div class="col-sm-12 col-md-4 col-lg-2" >
                    <select name="pay" id="category" class="form-control">
                        <option value="">全部</option>
                        {volist name=":config('pay')" id="vo"}
                        <option {eq name="$key" value="$Think.get.pay"}selected{/eq} value="{$key}">{$vo}</option>
                        {/volist}
                    </select>
                </div>
                <div class="col-sm-12 col-md-4 col-lg-2" >
                    <select name="buystatus"  class="form-control">
                        <option value="">全部</option>
                        <option {eq name="1" value="$Think.get.buystatus"}selected{/eq} value="1">待发货</option>
                        <option {eq name="2" value="$Think.get.buystatus"}selected{/eq} value="2">待配送</option>
                        <option {eq name="3" value="$Think.get.buystatus"}selected{/eq} value="3">待签收</option>
                        <option {eq name="4" value="$Think.get.buystatus"}selected{/eq} value="4">已完成</option>
                    </select>
                </div>
                <br />
                <div class="col-sm-12 col-md-4 col-lg-12" style="    text-align: right;    margin-top: 10px;">
                  <button class="btn btn-primary" type="submit">搜索</button>
                </div>
            </form>
        </div>


        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th width="30"><input class="checkbox check-all" type="checkbox"></th>
                    <th width="60">ID</th>
                    <th>微信名称</th>
                    <th>用户名</th>
                    <th>联系电话</th>
                    <th>所属单位</th>
                    <th>当日该单位编号</th>
                    <th>订单价格</th>
                    <th>下单时间</th>
                    <th>支付方式</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="item"}
                <tr>
                    <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item['id']}"></td>
                    <td>{$item['id']}</td>
                    <td>{$item['nick_name']} </td>
                    <td>{$item['user_name']} </td>
                    <td>{$item['tel']}</td>
                    <td>{$item['company_id']|get_table_field="id","title","company"}</td>
                    <td>{$item['day_no']}</td>
                    <td>{$item['total']} </td>

                    <td>{$item['create_time']}</td>
                    <td>{$item['pay']|parse_config_value='pay'}</td>
                    <td>{$item['buystatus']|parse_config_value='pay_status'}</td>
                    <td>
                        <a href="{:url('edit',array('id'=>$item['id']))}">查看</a>
                        {eq name=":session('user_auth.username')" value="admin"}<a href="{:url('del',array('id'=>$item['id']))}" class="confirm ajax-get">删除</a>{/eq}
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$list->render()}
        </div>
    </div>
</div>


<!-- 模态框（Modal） -->
<div class="modal fade" id="isPay" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">核对消息</h4>
            </div>
            <div class="modal-body"></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="orderNo" tabindex="-1" role="dialog" aria-labelledby="orderNoLabel" aria-hidden="true">
    <div class="modal-dialog">
        <form class="form-orderNo" action="{:url('addOrderNo')}" method="post">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="orderNoLabel">添加订单号</h4>
                </div>
                <div class="modal-body">
                    订单号：<input type="text" name="order_no"  value="">
                    <input type="hidden" name="id">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary submit-btn ajax-post"  target-form="form-orderNo">添加</button>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal -->
</div>


<!-- datepicker statr -->
<link href="__PUBLIC__/plugs/datepicker/css/foundation-datepicker.min.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.js"></script>
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/board/board.min.css">
<!-- datepicker end -->
<script type="text/javascript">
    $('[name="start"]').fdatepicker({
        format: 'yyyy-mm-dd hh:ii',
        pickTime: true
    });
    $('[name="end"]').fdatepicker({
        format: 'yyyy-mm-dd hh:ii',
        pickTime: true
    });

    // implementation of disabled form fields
    // var nowTemp = new Date();
    // var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
    // var checkin = $('[name="start"]').fdatepicker({
    // 	format: 'yyyy-mm-dd',
    // }).on('changeDate', function (ev) {
    // 	if (ev.date.valueOf() > checkout.date.valueOf()) {
    // 		var newDate = new Date(ev.date)
    // 		newDate.setDate(newDate.getDate() + 1);
    // 		checkout.update(newDate);
    // 	}
    // 	checkin.hide();
    // 	$('[name="end"]')[0].focus();
    // }).data('datepicker');
    // var checkout = $('[name="end"]').fdatepicker({
    // 	format: 'yyyy-mm-dd',
    // 	onRender: function (date) {
    // 		return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
    // 	}
    // }).on('changeDate', function (ev) {
    // 	checkout.hide();
    // }).data('datepicker');

    var shopsau = "{$shopsau}"
    if(shopsau){
        $('[name="rebate_code"]').parent().remove();
        $('[name="pay"]').parent().remove();
        $('[name="index_type"]').parent().remove();
    }


    ispayUrl = ''
    $('.ispay').click(function(){
        $('#isPay').modal('show')
        ispayUrl = $(this).attr('url')
    })
    $('#isPay').on('shown.bs.modal', function () {
        var $this = $(this)

        $.get(ispayUrl, function(data){
            console.log(data);
            $this.find('.modal-body').html(data.msg+',微信支付订单号	：'+data.data.transaction_id+',支付金额：'+(data.data.cash_fee/100))
        })
    })


    $('#orderNo').on('show.bs.modal', function (e) {
        var id = $(e.relatedTarget.outerHTML).attr('data-id');
        $(e.target).find('[name="id"]').val(id);
    })


</script>


{/block}
